<?php
/**
 * Created by PhpStorm.
 * User: MIS
 * Date: 2018/10/23
 * Time: 9:18
 */
namespace Admin\Controller;
use Think\Controller;
class SelectController extends Controller
{
    public function index(){
        $select= M();
        $id=I("id");
        $username=I("username");
        session("tid",$id);
        $s="select COUNT(id)  FROM ks_select  where tid='$id'";
        $count=$select->query($s);
        $sql="select id,content,select_a,select_b,select_c,select_d,success FROM ks_select where tid='$id'";
        $new_test=$select->query($sql);
        $this->assign("data",$new_test);
        $this->assign("username",$username);
        $this->assign('news_count',$count["0"]["COUNT(id)"]);
        $this->display();
    }
    public function  delete($id){
        $select=M('select');
        $a= $select->where('`id`='.$id)->delete();
        if($a){
            $this->success('该题删除成功',U('/Admin/Select/index',array('id'=>$_SESSION["id"])));
        }else{
            $this->error('该题删除失败');
        }
    }
    public function edit($id){
            redirect(U('/Admin/EditSelect/index',array('id'=>$id)));
    }

    public function add(){
        redirect(U('/Admin/EditSelect/index'));
    }


}